<script setup>
import axios from 'axios'
import { onMounted, ref } from 'vue'
import router from '../../router/router'
// const form = ref([])
const pagination = ref([])
const currentPage = ref(1)
const pageSize = ref(4)

onMounted(() => {
  handleCurrentChange()
})
const handleCurrentChange = () => {
  axios.get('api/examManagecontroller/findAll2/' + currentPage.value + '/' + pageSize.value).then(res => {
    pagination.value = res.data
  })
}

const toPart = (examCode, source) => {
  router.push({ path: '/scorePart', query: { examCode: examCode, source: source } })
}
</script>

<template>
<div class="exam">
    <el-table :data="pagination" :border="true">
      <el-table-column fixed="left" prop="source" label="试卷名称" width="180"></el-table-column>
      <el-table-column prop="description" label="介绍" width="200"></el-table-column>
      <el-table-column prop="institute" label="所属学院" width="120"></el-table-column>
      <el-table-column prop="major" label="所属专业" width="200"></el-table-column>
      <el-table-column prop="grade" label="年级" width="100"></el-table-column>
      <el-table-column prop="examDate" label="考试日期" width="120"></el-table-column>
      <el-table-column prop="totalTime" label="持续时间" width="120"></el-table-column>
      <el-table-column prop="totalScore" label="总分" width="120"></el-table-column>
      <el-table-column prop="type" label="试卷类型" width="120"></el-table-column>
      <el-table-column prop="tips" label="考生提示" width="400"></el-table-column>
      <el-table-column fixed="right" label="操作" width="150">
        <template  #default="scope">
          <el-button @click="toPart(scope.row.examCode,scope.row.source)" type="primary" size="small">查看分段</el-button>
        </template>
      </el-table-column>
    </el-table>
   <el-pagination
      v-model:currentPage="currentPage"
      v-model:page-size="pageSize"
      :page-sizes="[1,2,3]"
      :small="small"
      :disabled="disabled"
      :background="background"
      layout="total, sizes, prev, pager, next, jumper"
      :total="80"
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
    />
  </div>
</template>

<style lang="less" scoped>
.exam {
  padding: 0px 40px;
  .page {
    margin-top: 20px;
    display: flex;
    justify-content: center;
    align-items: center;
  }
  .edit{
    margin-left: 20px;
  }
}
</style>
